package chaoyue.study.controller;

import chaoyue.study.bean.Depart;
import chaoyue.study.client.FeignDepartClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("depart/feign")
public class FeignDepartController {
    @Autowired
    private FeignDepartClient client;

    @PostMapping("save")
    public void saveHandle(@RequestBody Depart depart) {
        client.save(depart);
    }

    @DeleteMapping("del/{id}")
    public void deleteHandle(@PathVariable("id") Integer id) {
        client.delete(id);
    }

    @PostMapping("update")
    public void updateHandle(@RequestBody Depart depart) {
        client.update(depart);
    }

    @GetMapping("get/{id}")
    public Depart getHandle(@PathVariable("id") Integer id) {
        return client.get(id);
    }

    @GetMapping("list")
    public List<Depart> listHandle() {
        return client.list();
    }
}
